<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>首页</title>
	<link rel="stylesheet" type="text/css" href="${ctxStatic}/common/index.css">
	<script type="text/javascript" src="${ctxStatic}/echarts/echarts.min.js"></script>
	<script type="text/javascript" src="${ctxStatic}/common/myslideup.js"></script>
	<script type="text/javascript" src="${ctxStatic}/common/base-loading.js"></script>
	<meta name="decorator" content="default"/>
</head>
<body>
<ul class="nav nav-tabs">
	<li class="active"><a href="${ctx}/stock/warning/">首页</a></li>
</ul>
<sys:message content="${message}"/>
<div class="container-fluid container_content">
	<div class="nav_title">
		<h2>物联网管理系统</h2>
		<h5>概览&统计</h5>
	</div>
	<!-- 公告DIV -->
	<div class="border_line nav_second_blank" style="height:30px;">
    <ul class="line">
     	<c:forEach items="${notList}" var="list">
	    	<li style="margin-top: 0px; ">
	    		<a title="${list.names}" href="${ctx}/sys/noticeInfo/list">${list.names}</a>
	    	</li>
	  </c:forEach>
    </ul>
	</div>

	<!--数据概况DIV -->
	<div class="row-fluid m_top10 task_category">
		<div class="span4">
			<div class="apart border_line">
				<h2>消息管理</h2>
				<h5>未读消息(<a href="${ctx}/news/news/unread_news_list" style="color:red">${unread}</a>)</h5>
				<h5>已读消息(<a href="${ctx}/news/news/read_news_list" style="color:red">${read}</a>)</h5>
				<div style="padding-top: 10px;">
					<shiro:hasPermission name="news:news:save">
						<a type="button" href="${ctx}/news/news/openSave" class="btn btn-primary" >创建消息</a>
					</shiro:hasPermission>
				</div>
			</div>
		</div>
		<div class="span4">
			<div class="apart border_line">
				<h2>账户余额<span style="color:red">(${kamt})</span></h2>
				<h5>已提金额(<a href="${ctx}/orders/withdrawalsOrder/list" style="color:red">${taskMoney}</a>)</h5>
				<h5>到账金额(<a href="${ctx}/orders/withdrawalsOrder/list" style="color:red">${arrivalMoney}</a>)</h5>
				<div style="padding-top: 10px;">
					<a type="button" onclick="batchDistribution()" class="btn btn-primary" >账户充值</a>
					<a type="button" onclick="checkInfo()" class="btn btn-primary" >账户提现</a>
				</div>
			</div>
		</div>
		<div class="span4">
			<div class="apart border_line">
				<h2>系统管理</h2>
				<div style="padding-top: 10px;">
					<shiro:hasPermission name="sys:office:edit">
						<a type="button" href="${ctx}/sys/office/form?id=${id}&types=2" class="btn btn-primary" >修改资料</a>
					</shiro:hasPermission>
					<a type="button" href="${ctx}/sys/opinion/openSave" class="btn btn-primary" >意见反馈</a>
					<a type="button" href="${ctx}/sys/user/openUpdatePassword?id=${userId}" class="btn btn-primary" >修改密码</a>
				</div>
			</div>
		</div>
		<div class="clear"></div>
	</div>

	<!-- 图表DIV-->
<%-- 	<div class="row-fluid search_condition">
		<h5>条件查询：</h5>
		<form class="form-inline">
				起止时间：<input name="createDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
					value="<fmt:formatDate value="${card.createDate}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>&nbsp;&nbsp;-&nbsp;&nbsp;
					<input name="createDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
					value="<fmt:formatDate value="${card.createDate}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
			<button type="" class="btn btn-primary">检索</button>
		</form>
	</div> --%>
	<div class="search_result">
				<div id="main" style="width: 1000px;height:400px;"></div>
	</div>
</div>
	<!-- 充值DIV -->
<form id="rechargeForm"  action="${ctx}/home/recharge" method="post" class="form-horizontal" accept-charset="UTF-8">
	<div id="myModal" style="width:400px;" class="modal hide fade" tabindex="-1" role="dialog"  aria-hidden="false">
	  <div class="modal-header">
	    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
	    <h3 id="myModalLabel">账户充值</h3>
	  </div>
		<div class="controls" style="margin-left: 5px;margin-top:10px;margin-bottom: 10px;">
			充值金额:<input style="width:180px;" path="money" digits="true" htmlEscape="false"  maxlength="10" minlength="1" class="input-xlarge required"/>
		</div>
	  <div class="modal-footer">
	    <button class="btn" data-dismiss="modal" aria-hidden="true" >取消</button>&nbsp;
	    <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>
	  </div>
	</div>
</form>
	<!-- 提现DIV -->
<form id="tixianForm"  action="${ctx}/home/task" method="post" class="form-horizontal">
	<div id="tixianModal" style="width:400px;" class="modal hide fade" tabindex="-1" role="dialog"  aria-hidden="false">
	  <div class="modal-header">
	    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
	    <h3 id="tixianModalLabel">账户提现</h3>
	  </div>
		<div class="controls" style="margin-left: 5px;margin-top:10px;margin-left: 10%;margin-bottom: 20px;">
			提现金额:<input placeholder="可提现金额${kamt}" style="width:180px;" name="taskMoney" id="taskMoney" digits="true" htmlEscape="false"  maxlength="10" minlength="1" class="input-xlarge required"/>
			
		</div>
		<span style="color:red;margin-left: 10%;">注意：</span></br>
		<span style="color:red;margin-left: 10%;">1.每笔提现将扣除2元的手续费</span></br>
		<span style="color:red;margin-left: 10%">2.请认真核对银行卡号和姓名是否正确，以免到账延误</span></br>
		<span style="color:red;margin-left: 10%;">3.银行卡号：${office.cardNo}</span></br>
		<span style="color:red;margin-left: 10%;">4.银行卡姓名：${office.cardName}</span></br>
		<span style="color:red;margin-left: 10%;">5.身份证号：${user.identity}</span>
	  <div class="modal-footer">
	    <button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>&nbsp;
	    <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>
	  </div>
	</div>
</form>
<!-- 补全DIV -->
<form id="complelteForm"  action="${ctx}/sys/user/complelte" method="post" class="form-horizontal">
	<div id="complelteModal" style="width:400px;" class="modal hide fade" tabindex="-1" role="dialog"  aria-hidden="false">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
			<h3 id="complelteLabel">补全信息</h3>
		</div>
		<div class="controls" style="margin-left: 5px;margin-top:10px;margin-left: 10%;margin-bottom: 20px;">
			银行卡:<input placeholder="请填写您的银行卡" style="width:180px;" name="cardNo" id="cardNo" digits="true" htmlEscape="false"  maxlength="20" minlength="1" class="input-xlarge required" value="${office.cardNo}"/>
		</div>
		<div class="controls" style="margin-left: 5px;margin-top:10px;margin-left: 10%;margin-bottom: 20px;">

			持卡人:<input placeholder="请填写持卡人姓名" style="width:180px;" name="cardName" id="cardName" digits="true" htmlEscape="false"  maxlength="20" minlength="1" class="input-xlarge required" value="${office.cardName}"/>
		</div>
		<div class="controls" style="margin-left: 5px;margin-top:10px;margin-left: 10%;margin-bottom: 20px;">
			身份证:<input placeholder="请填写您的身份证号" style="width:180px;" name="identity" id="identity" digits="true" htmlEscape="false"  maxlength="20" minlength="1" class="input-xlarge required" value="${user.identity}"/>
		</div>
		<div class="modal-footer">
			<button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>&nbsp;
			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>
		</div>
	</div>
</form>


<script type="text/javascript">
$(document).ready(function() {
	//表单验证
	$("#rechargeForm").validate({
		submitHandler: function(form){
			loading('正在提交，请稍等...');
			form.submit();
		},
	});
	
	$("#tixianForm").validate({
		rules:{
			taskMoney:{ 
            	checkMoney:true,
            }
        },
		submitHandler: function(form){
			loading('正在提交，请稍等...');
			form.submit();
		},
	});
	//公告滚动效果
	$(".line").slideUp();
	 $.validator.addMethod("checkMoney",function(value,element,params){ 
         var money = '${kamt}';
         return this.optional(element)||(parseInt(value) <parseInt(money));  
     },"提现金额不得大于可提现金额！");
});
//判断是否需要修改密码
if('${password}' == '7820a0ef94b71216c956b0d375090db3ab6ea9ce75644e8addf7fdd9'){
	$.jBox.prompt('检测到您还未修改初始密码，请修改初始密码', '提示信息', 'info', { 
		closed: function () { 
			window.location.href = '${ctx}/sys/user/openUpdatePassword?id='+${userId};
			} 
	});
}else{
	
}
//账户充值
function batchDistribution(){
	$.jBox.prompt('充值维护中，暂时不可充值...', '提示信息', 'info', {  
	});
		return false;
		$('#myModal').modal("show");//打开模态框
	}
//账户提现
function tixianBtn(){
		$('#tixianModal').modal("show");//打开模态框
	}
function checkInfo(){
    $.ajax({
        type: "get",
        async: true,
        url: "${ctx}/sys/user/checkInfoByUserId",
        contentType: "application/x-www-form-urlencoded;charset=utf-8",
        success: function (data) {
            var code=data.code;
            console.log(data);
            if(code=="3"){
                tixianBtn();
            }else if(code=="2"){
                completeInfo();
            }else {
               alert(data.msg)
            }
        }
    });

}
function completeInfo(){
    $('#complelteModal').modal("show");
}



//初始化图表标签
console.log('${dateList}'.split(","));
var myChart = echarts.init(document.getElementById('main'));
option = {
	    title: {
	        text: '近7天分润走势图'
	    },
	    tooltip: {
	        trigger: 'axis'
	    },
	    grid: {
	        left: '3%',
	        right: '4%',
	        bottom: '3%',
	        containLabel: true
	    },
	    toolbox: {
	        feature: {
	            saveAsImage: {}
	        }
	    },
	    xAxis: {
	        type: 'category',
	        boundaryGap: false,
	        data: '${dateList}'.split(","),
	        splitLine: { //设置X轴的网格
	            show: true,
	            interval: 'auto'
	        },
	        axisLine: { //设置X轴的颜色
	            lineStyle: {
	                color: 'blue'
	            }
	        }
	    },
	    yAxis: {
	        type: 'value',
	        axisLine: { //设置y轴的颜色
	            lineStyle: {
	                color: 'blue'
	            }
	        }
	    },
	    series: [{
	        name: '分润金额',
	        type: 'line',
	        stack: '总量',
	        smooth: true, //点与点之间的幅度,false为直线
	        label: { //设置点数据的提示
	            normal: {
	                show: true,
	                position: 'bottom'
	            }
	        },
	        data:'${weekDateList}'.split(","),
	        markPoint: { //设置最大值和最小值
	            data: [{
	                type: 'max',
	                name: '最大值'
	            }, {
	                type: 'min',
	                name: '最小值'
	            }]
	        }

	    }]
	};
myChart.setOption(option);
</script>
</body>
</html>